/* eslint-disable no-unused-vars */
import React, { useEffect } from "react";
import styles from './launch.module.css';
import { useHistory } from "react-router-dom/cjs/react-router-dom";
import { useDispatch } from "react-redux";
import icon_app_logo from "@/assets/icon_app_logo.png"
import { isLogin } from "@/utils/storage";
import { reqSaveEvent } from "@/store/actions/apiServices";

/**
 * 启动页
 */
export default function Launch() {

    //判断是否登录
    const checkLogin = isLogin()
    console.log("checkLogin: " + checkLogin)

    // 获取路由历史 history 对象
    const history = useHistory()

    //获取 Redux 分发器
    const dispatch = useDispatch()


    useEffect(() => {
        reqSaveEvent("LAUNCH_START")

        setTimeout(() => {
            history.replace("/install")
        }, 2000);

        return () => {
            reqSaveEvent("LAUNCH_END")
        }
    }, [])


    return (
        <div className={styles.launchRoot}>
            <img
                className={styles.launchImageSmall}
                src={icon_app_logo}
                alt="" />
            <span className={styles.launchTitle}>Onua  Credit</span>
        </div>
    )
}